package org.example.service.impl;

import cn.hutool.jwt.JWTUtil;
import org.example.config.R;
import org.example.domain.Grow;
import org.example.mapper.CropWorkMapper;
import org.example.mapper.GrowMapper;
import org.example.mapper.GrowWorkCenterMapper;
import org.example.service.GrowService;
import org.example.service.GrowWorkCenterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;

@Service
public class GrowServiceImpl implements GrowService {

    @Autowired
    GrowMapper growMapper;

    @Autowired
    GrowWorkCenterService growWorkCenterService;

    @Autowired
    HttpServletRequest request;


    @Override
    public R addGrow(Grow grow,Integer uid) {
        //1.生长情况表添加
        grow.setCreateTime(new Date());
        grow.setUpdateTime(new Date());
        grow.setCreater(uid);
        grow.setUpdater(uid);
        boolean b=growMapper.addGrow(grow);
        if(b){
            //2.添加到中间表
            growWorkCenterService.addGrowWorkCenter(grow);
        }

        return b?R.successed(null): R.failed(null);
    }
}
